package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import com.tanhua.model.domain.BlackList;
import com.tanhua.model.domain.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/11/30 21:01
 */

@DubboService
public class BlackListApiImpl implements BlackListApi{

    @Autowired
    private BlackListMapper blackListMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;

    /**
     * 黑名单分页查询
     * @param page
     * @param pageSize
     * @param userId
     * @return
     */
    @Override
    public IPage<UserInfo> findByPage(Integer page, Integer pageSize, Long userId) {

        Page Pages = new Page(page, pageSize);

        IPage<UserInfo> iPage = userInfoMapper.findByPage(Pages, userId);
        return iPage;
    }

    @Override
    public void delete(Long uid, Long userId) {

        LambdaQueryWrapper<BlackList> quereWrapper = new LambdaQueryWrapper<>();
        quereWrapper.eq(BlackList::getUserId, userId);
        quereWrapper.eq(BlackList::getBlackUserId, uid);
        blackListMapper.delete(quereWrapper);
    }


}
